/*MyPhotoIndex Free Photo Organizer <www.myphotoindex.com>
  Copyright (C) <2006-2009>  <Asaf Yarkoni asaf@yarkoni.net>

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.IO;
using MyPhotoIndex.Utilities;
using MyPhotoIndex.Utilities.ImageMetaData;
using MyPhotoIndex.Plugins.ImageFormatProviders;

namespace MyPhotoIndex.Importer.CameraImageAcquisition
{
    class RemovableDriveImage : IAcquiredImage
    {
        private ExifExtractor   m_imageData;
        private string          m_fileName;

        internal RemovableDriveImage(string fileName)
        {
            m_fileName = fileName;
            m_imageData = new ExifExtractor(fileName);
        }

        #region IAcquiredImage Members

        public void Transfer(string fileName)
        {
            File.Copy(m_fileName, fileName, false);
        }

        public void Delete()
        {
            try
            {
                File.Delete(m_fileName);
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
            }
        }

        public Image Thumbnail
        {
            get 
            {
                String extention = Path.GetExtension(m_fileName);
                return ImageFormatProviders.Default[extention].GetThumbnail(m_fileName, new Size(240, 160));
            }
        }

        public string FullName
        {
            get { return m_fileName; }
        }

        public string Name
        {
            get { return Path.GetFileName(m_fileName); }
        }

        public string FileExtention
        {
            get { return Path.GetExtension(m_fileName); }
        }

        public int ThumbnailHeight
        {
            get { return m_imageData.ThumbnailHeight; }
        }

        public int ThumbnailWidth
        {
            get { return m_imageData.ThumbnailWidth; }
        }

        public DateTime DateTaken
        {
            get { return m_imageData.DateTaken; }
        }

        #endregion
    }
}
